package adapter;

import android.annotation.SuppressLint;
import android.content.Context;
import android.support.annotation.Nullable;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import bean.CourseraBean;
import bean.MessageBean;
import student.andlei.com.student.R;

public class MessageAdapter extends BaseQuickAdapter<MessageBean.Data,BaseViewHolder> {
    public Context context;
    public MessageAdapter(Context context, int layoutResId, @Nullable List<MessageBean.Data> data) {
        super(layoutResId, data);
        this.context = context;
    }

    @Override
    protected void convert(BaseViewHolder helper, MessageBean.Data item) {
        //消息来源 1平台 2学校 3老师
        switch (item.message_type){
            case 1:
                helper.setText(R.id.tv_title,"(平台消息)  "+item.title);
                break;
            case 2:
                helper.setText(R.id.tv_title,"(学校消息)  "+item.title);
                break;
            case 3:
                helper.setText(R.id.tv_title,"(老师消息)  "+item.title);
                break;
            default:
                helper.setText(R.id.tv_title,item.title);
                break;
        }
        helper.setText(R.id.tv_content,item.content);
        helper.setText(R.id.tv_time,item.create_time);
        if(item.IsClick ==1){
            helper.getView(R.id.rlayout_bg).setBackgroundResource(R.color.activity_bg);
        }else {
            helper.getView(R.id.rlayout_bg).setBackgroundResource(R.color.white_1);
        }
        //状态 0未读 1已读
        if(item.status == 1){
            helper.getView(R.id.red_point).setVisibility(View.GONE);
        }else {
            helper.getView(R.id.red_point).setVisibility(View.VISIBLE);
        }
    }
}
